package com.happyfamily.springboot.crowdsourcingplatform.dao.sun;

import com.happyfamily.springboot.crowdsourcingplatform.model.Need;
import com.happyfamily.springboot.crowdsourcingplatform.model.SysUser;
import com.happyfamily.springboot.crowdsourcingplatform.model.Tender;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TenderDao
{

	//插入投标表的功能
	@Insert("INSERT INTO tender (pid,ttype,needid,userid,tstarttime) VALUES (32,#{ttype},#{needid},#{userid},#{tstarttime})")
	public abstract int addTender(Tender tender);

	//根据需求id和用户id查询某个投标情况
	@Select("SELECT * FROM tender WHERE userid=#{uid} AND needid=#{nid}")
	public abstract Tender getTender(Long uid,Long nid);

	//根据需求id和用户id删除某个投标
	@Delete("DELETE FROM tender WHERE userid=#{uid} AND needid=#{nid}")
	public abstract int deleteTender(Long uid,Long nid);

	@Select("SELECT needid FROM tender WHERE userid=#{aid} AND ttype='联盟投标' AND tendtime IS NOT NULL")
	public List<Long> getNeeds(Long aid);
}